/* eslint-disable @typescript-eslint/no-unused-vars */

export function getTableScroll({ ref, extraHeight }) {
  if (typeof extraHeight === 'undefined') {
    //  默认底部分页48 + 边距18 + 边距24
    extraHeight = 90;
  }
  let tHeader: any = null;
  if (ref && ref.current) {
    tHeader = ref.current.getElementsByClassName('ant-table-thead')[0];
  } else {
    tHeader = document.getElementsByClassName('ant-table-thead')[0];
  }
  // 表格内容距离顶部的距离
  let tHeaderBottom = 0;
  if (tHeader) {
    tHeaderBottom = tHeader.getBoundingClientRect().bottom;
  }
  // 窗体高度-表格内容顶部的高度-表格内容底部的高度
  // let height = document.body.clientHeight - tHeaderBottom - extraHeight
  const height = `calc(100vh - ${tHeaderBottom + extraHeight}px)`;
  // 空数据的时候表格高度保持不变,暂无数据提示文本图片居中
  // if (ref && ref.current) {
  //   const placeholder = ref.current.getElementsByClassName('ant-table-placeholder')[0];
  //   if (placeholder) {
  //     placeholder.style.height = height;
  //     placeholder.style.display = 'flex';
  //     placeholder.style.alignItems = 'center';
  //     placeholder.style.justifyContent = 'center';
  //   }
  // }
  return height;
}
